package cn.fastoo.common.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;

public class ChargeUtil {

    protected static Logger logger = LoggerFactory.getLogger(ChargeUtil.class);

    public static void charge(JdbcTemplate jdbcTemplate, double cost, String apiKey, String da) {
        jdbcTemplate.update("UPDATE user_base a INNER JOIN user_account b on a.id = b.user_base_id AND b.api_key = ? SET a.balance = a.balance - ?", apiKey, cost);
        logger.info("api da:" + da + ",apiKey:" + apiKey + ",cost:" + cost);
    }

}
